<!-- UserController.php-->
<?php 
	require 'Admin/Model/typeModel.php';
	require 'Controller.php';
	class typeController extends Controller{
		function listtypes(){
			$model = new typeModel();
			$data = $model->gettypeList();
			//转向用户列表页面
			include 'Admin/View/type/listtypes.php';
		}

		function form(){
			//转向添加用户页面
			include 'Admin/View/type/form.php';
		}

		function noveltypeedit(){
			$id = $_GET['id'];
			$model = new typemodel();
			$result = $model->getUserByID($id);
			include 'Admin/View/type/noveltypeedit.php';
		}

	

		function typeupdate(){
			$id = $_GET['id'];
			$model = new typemodel();
			$result = $model->Updatetype($id);
			if($result){
				echo '修改成功'.'<a href="admin.php?c=type&m=listtypes">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=type&m=listtypes"); 	
			}else{
				echo '失败';
			}
		}

		function deltype(){
			$id = $_GET['id'];
			$model = new typemodel();
			$result = $model->Deltype($id);
			if($result){
				echo '删除成功'.'<a href="admin.php?c=type&m=listtypes">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=type&m=listtypes = admin.php?c=type&m=listtypes"); 
			}else{
				echo '删除失败';
			}
		}

		function addtype(){
			//获取表单的数据
			//调用model中的addUser方法，添加到数据库中
			//var_dump($_POST);
			$data = $_POST;
			$model = new typemodel();
			$result = $model->addtype($data);
			//如果成功，输出，转到列表页面
			if($result){
				echo '添加成功'.'<a href="admin.php?c=type&m=listtypes">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=type&m=listtypes"); 
			}else{
				echo '失败';
			}

		}
	}
 ?>